package logic

import (
	"context"
	"house_srv/mysql"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseShowLogic) HouseShow(in *house.HouseShowRequest) (*house.HouseShowResponse, error) {
	// todo: add your logic here and delete this line
	houses := mysql.House{}
	err := houses.HouseInfo(in.HouseId)
	if err != nil {
		logx.Info("房源详情信息错误")
		return nil, err
	}
	return &house.HouseShowResponse{
		UserId:    houses.UserId,
		HouseName: houses.HouseName,
		Price:     houses.Price,
		Floor:     houses.Floor,
		Area:      houses.Area,
		Cover:     houses.Cover,
		Address:   houses.Address,
		Describe:  houses.Describe,
		HouseId:   int64(houses.ID),
	}, nil
}
